home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-10 | 12.3 KB | 388 lines | [TEXT/MPS ] |
- UNIT MIDI;
-
- {
- MIDI.p
-
- This file contains the pascal-language interface for the MIDI Manager.
-
- Author: John Worthington, Don Marsh, Mark Lentczner
- Copyright © 1988-90, Apple Computer, Inc.
- All Rights Reserved
- }
-
-
- INTERFACE
-
- USES
- MemTypes,
- QuickDraw,
- OSIntf;
-
-
- CONST
-
- midiToolNum = 4; {tool number of MIDI Manager for SndDispVersion call}
-
- midiMaxNameLen = 31; {maximum number of characters in port and client names}
-
-
- {Time formats}
-
- midiFormatMSec = 0; {milliseconds}
- midiFormatBeats = 1; {beats}
- midiFormat24fpsBit = 2; {24 frames/sec.}
- midiFormat25fpsBit = 3; {25 frames/sec.}
- midiFormat30fpsDBit = 4; {30 frames/sec. drop-frame}
- midiFormat30fpsBit = 5; {30 frames/sec.}
- midiFormat24fpsQF = 6; {24 frames/sec.longInt format}
- midiFormat25fpsQF = 7; {25 frames/sec.longInt format}
- midiFormat30fpsDQF = 8; {30 frames/sec. drop-frame longInt format}
- midiFormat30fpsQF = 9; {30 frames/sec.longInt format}
-
- midiInternalSync = 0; {internal sync}
- midiExternalSync = 1; {external sync}
-
-
- {Port types}
-
- midiPortTypeTime = 0; {time port}
- midiPortTypeInput = 1; {input port}
- midiPortTypeOutput = 2; {output port}
- midiPortTypeTimeInv = 3; {invisible time port}
- midiPortInvisible = $8000; {add this to above to make ports invisible}
- midiPortTypeMask = $0007; {AND with this to convert new port types to old,
- ie. to strip property bits}
-
-
- {OffsetTimes}
-
- midiGetEverything = $7FFFFFFF; {get all packets, regardless of time stamps}
- midiGetNothing = $80000000; {get no packets, regardless of time stamps}
- midiGetCurrent = $00000000; {get current packets only}
-
-
-
-
- {
- MIDI data and messages are passed in MIDIPacket records (see below).
- The first byte of every MIDIPacket contains a set of flags
-
- bits 0-1 00 = new MIDIPacket, not continued
- 01 = begining of continued MIDIPacket
- 10 = end of continued MIDIPacket
- 11 = continuation
- bits 2-3 reserved
-
- bits 4-6 000 = packet contains MIDI data
- 001 = packet contains MIDI Manager message
-
- bit 7 0 = MIDIPacket has valid stamp
- 1 = stamp with current clock
- }
-
- midiContMask = $03;
- midiNoCont = $00;
- midiStartCont = $01;
- midiMidCont = $03;
- midiEndCont = $02;
-
- midiTypeMask = $70;
- midiMsgType = $00;
- midiMgrType = $10;
-
- midiTimeStampCurrent = $80;
- midiTimeStampValid = $00;
- midiTimeStampMask = $80;
-
-
- {MIDI Manager MIDIPacket command words (the first word in the
- data field for midiMgrType messages) }
-
- midiOverflowErr = $0001;
- midiSCCErr = $0002;
- midiPacketErr = $0003;
- midiMaxErr = $00FF; {all command words less than this value}
- { are error indicators}
-
-
- {valid results to be returned by readHooks}
-
- midiKeepPacket = 0;
- midiMorePacket = 1;
- midiNoMorePacket = 2;
-
-
- {
- Errors:
- }
-
- midiNoClientErr = -250; {no client with that ID found}
- midiNoPortErr = -251; {no port with that ID found}
- midiTooManyPortsErr = -252; {too many ports already installed in the system}
- midiTooManyConsErr = -253; {too many connections made}
- midiVConnectErr = -254; {pending virtual connection created}
- midiVConnectMade = -255; {pending virtual connection resolved}
- midiVConnectRmvd = -256; {pending virtual connection removed}
- midiNoConErr = -257; {no connection exists between specified ports}
- midiWriteErr = -258; {MIDIWritePacket couldn't write to all connected ports}
- midiNameLenErr = -259; {name supplied is longer than 31 characters}
- midiDupIDErr = -260; {duplicate client ID}
- midiInvalidCmdErr = -261; {command not supported for port type}
-
-
-
- {
- Driver calls:
- }
-
- midiOpenDriver = 1;
- midiCloseDriver = 2;
-
-
- {
- All notes off:
- }
-
- mdvrAbortNotesOff = 0; { abort previous mdvrNotesOff request }
- mdvrChanNotesOff = 1; { generate channel note off messages }
- mdvrAllNotesOff = 2; { generate all note off messages }
-
- mdvrStopOut = 0; { stop calling the MDVROut temporarily }
- mdvrStartOut = 1; { resume calling MDVROut }
-
- TYPE
-
- {
- MIDI data and other messages are read and written in packets:
- }
-
- MIDIPacket = PACKED RECORD
- flags : BYTE;
- len : BYTE;
- tStamp : LONGINT;
- data : PACKED ARRAY [0..248] OF BYTE;
- END;
- MIDIPacketPtr = ^ MIDIPacket;
-
-
- {
- Clocks:
- }
-
- MIDIClkInfo = RECORD
- sync : INTEGER; {synchronization internal/external}
- curTime : LONGINT; {current value of port's clock}
- format : INTEGER; {time code format}
- END;
-
-
-
- {
- port information
- }
-
- MIDIIDRec = RECORD
- clientID : OSType;
- portID : OSType;
- END;
-
- MIDIPortInfo = RECORD
- portType : INTEGER; {type of port}
- timeBase : MIDIIDRec; {MIDIIDRec for time base}
- numConnects : INTEGER; {number of connections}
- cList : ARRAY [1..100] OF MIDIIDRec
- {the connections}
- END;
-
- MIDIPortInfoPtr = ^ MIDIPortInfo;
- MIDIPortInfoHdl = ^ MIDIPortInfoPtr;
-
-
- MIDIPortParams = RECORD
- portID : OSType; {ID of port, unique within client}
- portType : INTEGER; {Type of port - input, output, time, etc.}
- timeBase : INTEGER; {refnum of time base, 0 if none}
- offsetTime : LONGINT; {offset for current time stamps}
- readHook : Ptr; {routine to call when input data is valid}
- refCon : LONGINT; {refcon for port (for client use)}
- initClock : MIDIClkInfo; {initial info for a time base}
- name : Str255; {name of the port}
- END;
-
- MIDIPortParamsPtr = ^ MIDIPortParams;
-
-
- {
- ID List
- }
- MIDIIDList = RECORD
- numIDs : INTEGER;
- list : ARRAY [1..100] of OSTYPE;
- END;
- MIDIIDListPtr = ^ MIDIIDList;
- MIDIIDListHdl = ^ MIDIIDListPtr;
-
- { MDVR record declarations }
-
- MDVRInCtlRec = RECORD
- timeCodeClock : Integer; { refnum of time base for time code }
- timeCodeFormat : Integer; { format of time code output }
- readProc : ProcPtr; { proc to call with input characters }
- commProc : ProcPtr; { proc to call for handshaking }
- refCon : LONGINT; { refCon passed to readProc, commProc }
- END;
-
- MDVRInCtlPtr = ^MDVRInCtlRec;
-
- MDVROutCtlRec = RECORD
- timeCodeClock : Integer; { time base driven by time code }
- timeCodeFormat : Integer; { format of time code to listen to }
- timeCodeProc : ProcPtr; { proc called on time code fmt change }
- commProc : ProcPtr; { proc to call for handshaking }
- refCon : LONGINT; { refCon passed to timeCodeProc }
- timeCodeFilter : Boolean; { filter time code if true }
- midiMsgTicks : LONGINT; { value of Ticks when MIDI msg rcvd }
- timeCodeTicks : LONGINT; { value of Ticks when time code rcvd }
- END;
-
- MDVROutCtlPtr = ^MDVROutCtlRec;
-
- MDVRPtr = Ptr;
-
-
-
- { Prototype Declarations for readHooks and timeProcs }
- {
- FUNCTION myReadHook(myPacket : MIDIPacketPtr; myRefCon : LONGINT) : INTEGER;
-
- PROCEDURE myTimeProc(curTime : LONGINT; myRefCon : LONGINT);
-
- PROCEDURE connectionProc(refnum:INTEGER; refCon:LONGINT;
- portType:INTEGER; clientID:OSType; portID:OSType;
- connect:BOOLEAN; direction:INTEGER);
-
- }
-
- { Prototype Declarations for driver routines }
- {
- FUNCTION CommProc (refnum : INTEGER; request: INTEGER; refCon: LONGINT): LONGINT;
- PROCEDURE TimeCodeProc( refnum : INTEGER; newFormat : INTEGER; refCon : LONGINT);
- PROCEDURE ReadProc (char: ^midiChars, length INTEGER; refCon LONGINT);
- }
-
-
- { MIDI Manager Routines }
-
- FUNCTION SndDispVersion(toolnum : INTEGER) : LONGINT;
-
- FUNCTION MIDISignIn(ID : OSTYPE; refCon : longint; icon : Handle; name : STR255) : OSErr;
- INLINE $203C,4,midiToolNum,$A800;
- PROCEDURE MIDISignOut(ID :OSTYPE);
- INLINE $203C,8,midiToolNum,$A800;
- FUNCTION MIDIGetClients : MIDIIDListHdl;
- INLINE $203C,12,midiToolNum,$A800;
- PROCEDURE MIDIGetClientName(ID : OSTYPE; VAR name : STR255);
- INLINE $203C,16,midiToolNum,$A800;
- PROCEDURE MIDISetClientName(ID : OSTYPE; name : STR255);
- INLINE $203C,20,midiToolNum,$A800;
- FUNCTION MIDIGetPorts(clientID : OSTYPE) : MIDIIDListHdl;
- INLINE $203C,24,midiToolNum,$A800;
- FUNCTION MIDIAddPort(clientID: OSTYPE; BufSize : integer;
- var refnum : integer; init : MIDIPortParamsPtr) : OSErr;
- INLINE $203C,28,midiToolNum,$A800;
- FUNCTION MIDIGetPortInfo(clientID : OSTYPE; portID : OSTYPE) : MIDIPortInfoHdl;
- INLINE $203C,32,midiToolNum,$A800;
- FUNCTION MIDIConnectData(srcClID, srcPortID, dstClID, dstPortID : OSTYPE) : OSErr;
- INLINE $203C,36,midiToolNum,$A800;
- FUNCTION MIDIUnConnectData(srcClID, srcPortID, dstClID, dstPortID : OSTYPE) : OSErr;
- INLINE $203C,40,midiToolNum,$A800;
- FUNCTION MIDIConnectTime(srcClID, srcPortID, dstClID, dstPortID : OSTYPE) : OSErr;
- INLINE $203C,44,midiToolNum,$A800;
- FUNCTION MIDIUnConnectTime(srcClID, srcPortID, dstClID, dstPortID : OSTYPE) : OSErr;
- INLINE $203C,48,midiToolNum,$A800;
- PROCEDURE MIDIFlush(refnum : integer);
- INLINE $203C,52,midiToolNum,$A800;
- FUNCTION MIDIGetReadHook(refnum : integer) : ProcPtr;
- INLINE $203C,56,midiToolNum,$A800;
- PROCEDURE MIDISetReadHook(refnum : integer; hook : ProcPtr);
- INLINE $203C,60,midiToolNum,$A800;
- PROCEDURE MIDIGetPortName(client : OSTYPE; port : OSTYPE; VAR name : STR255);
- INLINE $203C,64,midiToolNum,$A800;
- PROCEDURE MIDISetPortName(client : OSTYPE; port : OSTYPE; name : STR255);
- INLINE $203C,68,midiToolNum,$A800;
- PROCEDURE MIDIWakeUp(refnum : integer; time : longint; period : longint; timeProc : ProcPtr);
- INLINE $203C,72,midiToolNum,$A800;
- PROCEDURE MIDIRemovePort(refnum : integer);
- INLINE $203C,76,midiToolNum,$A800;
- FUNCTION MIDIGetSync(refnum : integer) : integer;
- INLINE $203C,80,midiToolNum,$A800;
- PROCEDURE MIDISetSync(refnum : integer; sync : integer);
- INLINE $203C,84,midiToolNum,$A800;
- FUNCTION MIDIGetCurTime(refnum : integer) : longint;
- INLINE $203C,88,midiToolNum,$A800;
- PROCEDURE MIDISetCurTime(refnum : integer; time : longint);
- INLINE $203C,92,midiToolNum,$A800;
- PROCEDURE MIDIStartTime(refnum : integer);
- INLINE $203C,96,midiToolNum,$A800;
- PROCEDURE MIDIStopTime(refnum : integer);
- INLINE $203C,100,midiToolNum,$A800;
- PROCEDURE MIDIPoll(refnum : integer; offsetTime : longint);
- INLINE $203C,104,midiToolNum,$A800;
- FUNCTION MIDIWritePacket(refnum : integer; packet : MIDIPacketPtr) : OSErr;
- INLINE $203C,108,midiToolNum,$A800;
- FUNCTION MIDIWorldChanged(clientID : OSTYPE) : BOOLEAN;
- INLINE $203C,112,midiToolNum,$A800;
- FUNCTION MIDIGetOffsetTime(refnum : integer) : longint;
- INLINE $203C,116,midiToolNum,$A800;
- PROCEDURE MIDISetOffsetTime(refnum : integer; offsetTime : longint);
- INLINE $203C,120,midiToolNum,$A800;
- FUNCTION MIDIConvertTime(srcformat : integer; dstformat : integer; time : longint) : longint;
- INLINE $203C,124,midiToolNum,$A800;
- FUNCTION MIDIGetRefCon(refnum : integer) : longint;
- INLINE $203C,128,midiToolNum,$A800;
- PROCEDURE MIDISetRefCon(refnum : integer; refCon : longint);
- INLINE $203C,132,midiToolNum,$A800;
- FUNCTION MIDIGetClRefCon(clientID : OSTYPE) : longint;
- INLINE $203C,136,midiToolNum,$A800;
- PROCEDURE MIDISetClRefCon(clientID : OSTYPE; refCon : longint);
- INLINE $203C,140,midiToolNum,$A800;
- FUNCTION MIDIGetTCFormat(refnum : integer) : integer;
- INLINE $203C,144,midiToolNum,$A800;
- PROCEDURE MIDISetTCFormat(refnum : integer; format : integer);
- INLINE $203C,148,midiToolNum,$A800;
- PROCEDURE MIDISetRunRate(refnum : integer; rate : integer; time : longint);
- INLINE $203C,152,midiToolNum,$A800;
- FUNCTION MIDIGetClientIcon(ID : OSTYPE) : Handle;
- INLINE $203C,156,midiToolNum,$A800;
- FUNCTION MIDICallAddress(callNum : integer): ProcPtr;
- INLINE $203C,164,midiToolNum,$A800;
- PROCEDURE MIDIsetConnectionProc(refnum: integer; connectionProc: ProcPtr; refCon : longint);
- INLINE $203C,168,midiToolNum,$A800;
- PROCEDURE MIDIGetConnectionProc(refnum: integer; VAR connectionProc: ProcPtr; VAR refCon : longint);
- INLINE $203C,172,midiToolNum,$A800;
- PROCEDURE MIDIDiscardPacket(refnum: integer; packet: MIDIPacketPtr);
- INLINE $203C,176,midiToolNum,$A800;
- FUNCTION MDVRSignIn(clientID : OSTYPE; refCon: longint; icon: Handle; name : Str255): OSErr;
- INLINE $203C,180,midiToolNum,$A800;
- PROCEDURE MDVRSignOut(clientID : OSTYPE);
- INLINE $203C,184,midiToolNum,$A800;
- FUNCTION MDVROpen(portType : integer; refnum : integer): MDVRPtr;
- INLINE $203C,188,midiToolNum,$A800;
- PROCEDURE MDVRClose(portPtr: MDVRPtr);
- INLINE $203C,192,midiToolNum,$A800;
- PROCEDURE MDVRControlIn(portPtr: MDVRPtr; inputCtl: MDVRPtr);
- INLINE $203C,196,midiToolNum,$A800;
- PROCEDURE MDVRControlOut(portPtr: MDVRPtr; outputCtl: MDVROutCtlPtr);
- INLINE $203C,200,midiToolNum,$A800;
- PROCEDURE MDVRIn(portPtr: MDVRPtr);
- INLINE $203C,204,midiToolNum,$A800;
- PROCEDURE MDVROut(portPtr: MDVRPtr; dataPtr : Ptr; length : integer);
- INLINE $203C,208,midiToolNum,$A800;
- PROCEDURE MDVRNotesOff(portPtr: MDVRPtr; mode : integer);
- INLINE $203C,212,midiToolNum,$A800;
-
-
- IMPLEMENTATION
-
- END.
-